<?php
$host=$_POST['host']; $port=$_POST['port']; $dbu=$_POST['dbu']; $dbp=$_POST['dbp'];

$connector='../.db/connect.php';
@file_put_contents($connector,"
<?php
\$db=isset(\$database)?(\$database?';dname='.\$database:''):';dbname=sitegeist';
//\$db='sitegeist';
//echo'*connecting to db: '.\$db.'xx*';
\$host='$host';
\$port='$port';
\$dbu='$dbu';
\$dbp='$dbp';
\$db=new PDO(\"mysql:host=\$host;port=\$port\$db\",\$dbu,\$dbp,array(
	PDO::MYSQL_ATTR_INIT_COMMAND=>\"SET NAMES utf8\" 
));
\$db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
//\$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY:: ?? );
?>
");

unset($_POST['host']); unset($_POST['port']); unset($_POST['dbu']); unset($_POST['dbp']);
if(!@file_exists($connector)){ echo'connector: failing write privileges on host'; exit; }
?>